package com.thinkinjava.genericity;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @Description
 * @Author
 * @Date 2019/11/14 18:50
 **/
public class RandomList<T> {
    private List<T> storage =new ArrayList<T>();
    private Random random=new Random(47);
    public boolean add(T a){
        return storage.add(a);
    }
    public T select(){
        return storage.get(random.nextInt(storage.size()));
    }

    public static void main(String[] args) {
        RandomList<Integer> integerRandomList = new RandomList<>();
        integerRandomList.add(1);
        integerRandomList.add(2);
        Integer select = integerRandomList.select();
        System.out.println(select);
    }
}
